//
//  MRSetUpViewController.m
//  MoRan
//
//  Created by MoRan on 2022.
//  Copyright © 2022 MoRan. All rights reserved.
//

#import "MRSetUpViewController.h"

#import "MRTrySubscribeCell.h"
#import "MRCurrencySelectCell.h"

@interface MRSetUpViewController ()

@end

@implementation MRSetUpViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib

    self.navigationBar.backgroundColor = [UIColor clearColor];
    [self setNavigationItemTitleViewWithTitle:@"我的"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"MRTrySubscribeCell" bundle:nil] forCellReuseIdentifier:@"MRTrySubscribeCell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"MRCurrencySelectCell" bundle:nil] forCellReuseIdentifier:@"MRCurrencySelectCell"];
    
    self.tableView.frame = CGRectMake(0,self.navigationBarHeight, kScreenWidth, kScreenHeight - self.navigationBarHeight);
}

- (void)addBackImageView {
    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [SVProgressHUD dismiss];
    [self refreshData];
}

#pragma mark - cellDataSource

- (NSArray *)cellDataSource {
    
    if (!self.dataSource) {
        NSMutableArray *arr = [NSMutableArray arrayWithCapacity:4];
        
        __block NSMutableArray *subarr = nil;
        __block NSDictionary *dict = nil;
             
//        subarr = [NSMutableArray arrayWithCapacity:1];
//
//        dict =  @{@"class":MRTrySubscribeCell.class,
//                  @"height":@([MRTrySubscribeCell getCellFrame:[NSNumber numberWithFloat:(kScreenWidth - 15*2)*155/345 + 50]]),
//                  @"delegate":@YES};
//        [subarr addObject:dict];
//
//        [arr addObject:subarr];
        
        //第二段
        subarr = [NSMutableArray arrayWithCapacity:1];
    
        //服务条款
        dict =  @{@"class":MRCurrencySelectCell.class,
                  @"height":@([MRCurrencySelectCell getCellFrame:[NSNumber numberWithFloat:60]]),
                  @"data":[MRCurrencySelectCellModel ittemModelWithTitle:@"服务条款"],
                  @"delegate":@YES};
        [subarr addObject:dict];
        
        //隐私政策
        dict =  @{@"class":MRCurrencySelectCell.class,
                  @"height":@([MRCurrencySelectCell getCellFrame:[NSNumber numberWithFloat:60]]),
                  @"data":[MRCurrencySelectCellModel ittemModelWithTitle:@"隐私政策"],
                  @"delegate":@YES};
        [subarr addObject:dict];
        
        [arr addObject:subarr];

        self.dataSource = arr;
    }
    return self.dataSource;
}

#pragma mark GCFreeTrialButtonCellDelegate

- (void)trySubscribeCell:(MRTrySubscribeCell *)cell button:(UIButton *)sender {
    [self gotoSubscribeViewController];
}

#pragma mark GPCurrencySelectCellDelegate 服务条款 隐私政策

- (void)currencySelectCell:(MRCurrencySelectCell *)cell button:(UIButton *)sender {
    [self gotoBaseWebViewController:cell.model.title url:@""];
}

@end

